package com.gpframework.module.order.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.order.domain.GpProductDetails;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;

/**
 * @ClassName GpProductDetailsReq
 * @Author gpframework
 * @Date 2023-06-16
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class GpProductDetailsReq extends BaseReq {
    private static final long serialVersionUID = 1L;

         @ApiModelProperty("品牌id")
     private String brandId;
     @ApiModelProperty("品牌名称")
     private String brandName;
     @ApiModelProperty("订单ID")
     private Long orderId;
     @ApiModelProperty("产品ID")
     private Long productId;
     @ApiModelProperty("产品单位标签名称")
     private String productUnitTagName;
     @ApiModelProperty("产品邮寄单位名称")
     private String productPostUnitName;
     @ApiModelProperty("数量标签")
     private String quantityTag;
     @ApiModelProperty("分支数量")
     private BigDecimal branchesQuantity;

    /**
    * @Description 生成查询wrapper
    * @Author greatplan@qq.com
    * @Date 2020-11-04 16:04
    * @Param [lqw]
    * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
    * @Return void
    */
    public void generatorQuery(QueryWrapper<GpProductDetails> lqw,boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias+"del_status",0);
        }
        if (StringUtils.isNotBlank(this.getBrandId())){
        lqw.eq(alias+"brand_id" ,this.getBrandId());
        }
        if (StringUtils.isNotBlank(this.getBrandName())){
            lqw.like(alias+"brand_name",this.getBrandName());
        }
        if (this.getOrderId() != null){
        lqw.eq(alias+"order_id" ,this.getOrderId());
        }
        if (this.getProductId() != null){
        lqw.eq(alias+"product_id" ,this.getProductId());
        }
        if (StringUtils.isNotBlank(this.getProductUnitTagName())){
            lqw.like(alias+"product_unit_tag_name",this.getProductUnitTagName());
        }
        if (StringUtils.isNotBlank(this.getProductPostUnitName())){
            lqw.like(alias+"product_post_unit_name",this.getProductPostUnitName());
        }
        if (StringUtils.isNotBlank(this.getQuantityTag())){
        lqw.eq(alias+"quantity_tag" ,this.getQuantityTag());
        }
        if (this.getBranchesQuantity() != null){
        lqw.eq(alias+"branches_quantity" ,this.getBranchesQuantity());
        }
    }
}
